package day04;

import util.CookieUtil;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/saveCookie")
public class SaveCookieServlet extends HttpServlet {


    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) {
        System.out.println("SaveCookieServlet.service()");

        String username="abc啊";


        // username=URLEncoder.encode(username,"utf-8");
        //
        // System.out.println("username = " + username);
        //
        // Cookie cookie=new Cookie("username",username);
        //
        // cookie.setMaxAge(60*60*24*7);
        //
        // // cookie.setPath(request.getContextPath()+"/emp");
        //
        //
        // response.addCookie(cookie);

        CookieUtil.addCookie("username",username,response);


    }
}
